using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class PoemSkill1Area : TriggerSkillCollider
{
    public override void Initialize(SkillData data, float radius, bool isShow = true)
    {
        base.Initialize(data, radius, isShow);

        transform.position = owner.transform.position;
        transform.localScale = new Vector3(radius * 0.2f, radius * 0.2f, 1);
        StartCoroutine(ThisSkill(data));
    }

    private IEnumerator ThisSkill(SkillData info)
    {
        var sprite1 = GetComponent<SpriteRenderer>();
        sprite1.color = new Color(1, 1, 1, 0);
        sprite1.DOFade(1, 0.4f);
        yield return new WaitForSeconds(0.4f);

        foreach (GameObject obj in targets.ToList())
        {
            if (obj.TryGetComponent(out Damageable tar))
            {
                owner.ApplyDamage(tar, info, canFeedback);
                new Buff_DamageBonus(5, 3).Apply(owner, tar);
            }
        }
        Destroy();
    }
}
